N = 2;
D = 12;
proM = 100;
disM = 20;
Offspring = [[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99, 0.1, 0.2],
                     [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.99, 0.1, 0.2, 0.3, 0.9]];
Lower = zeros(N,D);
Upper = ones(N,D) ;
Site  = rand(N,D) < proM/D;
% mu    = rand(N,D);
mu = Offspring;
Off = Offspring;
% temp  = Site & mu<=0.5;
% Offspring(temp) = Offspring(temp)+(Upper(temp)-Lower(temp)).*((2.*mu(temp)+(1-2.*mu(temp)).*...
%                     (1-(Offspring(temp)-Lower(temp))./(Upper(temp)-Lower(temp))).^(disM+1)).^(1/(disM+1))-1);
% temp = Site & mu>0.5;
% Offspring(temp) = Offspring(temp)+(Upper(temp)-Lower(temp)).*(1-(2.*(1-mu(temp))+2.*(mu(temp)-0.5).*...
%                     (1-(Upper(temp)-Offspring(temp))./(Upper(temp)-Lower(temp))).^(disM+1)).^(1/(disM+1)));
% disp(Offspring);
%    
temp  = Site & mu<=0.5;
Off1 = Offspring+(Upper-Lower).*((2.*mu+(1-2.*mu).*...
                    (1-(Offspring-Lower)./(Upper-Lower)).^(disM+1)).^(1/(disM+1))-1);
Off(temp) = Off1(temp);
temp = Site & mu>0.5;
Off2 = Offspring+(Upper-Lower).*(1-(2.*(1-mu)+2.*(mu-0.5).*...
                    (1-(Upper-Offspring)./(Upper-Lower)).^(disM+1)).^(1/(disM+1)));
Off(temp) = Off2(temp);
disp(Off);